package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.business.domain.CzEquipmentAttr;
import com.ruoyi.business.service.ICzEquipmentAttrService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备信息Controller
 * 
 * @author ruoyi
 * @date 2022-02-07
 */
@Api(tags = "设备信息")
@RestController
@RequestMapping("/business/equipment_attr")
public class CzEquipmentAttrController extends BaseController
{
    @Autowired
    private ICzEquipmentAttrService czEquipmentAttrService;

    /**
     * 查询设备信息列表
     */
    @ApiOperation(value = "查询设备信息列表")
    @PreAuthorize("@ss.hasPermi('business:equipment_attr:list')")
    @GetMapping("/list")
    public TableDataInfo list(CzEquipmentAttr czEquipmentAttr)
    {
        startPage();
        List<CzEquipmentAttr> list = czEquipmentAttrService.selectCzEquipmentAttrList(czEquipmentAttr);
        return getDataTable(list);
    }

    /**
     * 导出设备信息列表
     */
    @ApiOperation(value = "导出设备信息列表")
    @PreAuthorize("@ss.hasPermi('business:equipment_attr:export')")
    @Log(title = "设备信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CzEquipmentAttr czEquipmentAttr)
    {
        List<CzEquipmentAttr> list = czEquipmentAttrService.selectCzEquipmentAttrList(czEquipmentAttr);
        ExcelUtil<CzEquipmentAttr> util = new ExcelUtil<CzEquipmentAttr>(CzEquipmentAttr.class);
        util.exportExcel(response, list, "设备信息数据");
    }

    /**
     * 获取设备信息详细信息
     */
    @ApiOperation(value = "获取设备信息详细信息")
    @PreAuthorize("@ss.hasPermi('business:equipment_attr:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(czEquipmentAttrService.selectCzEquipmentAttrById(id));
    }

    /**
     * 新增设备信息
     */
    @ApiOperation(value = "新增设备信息")
    @PreAuthorize("@ss.hasPermi('business:equipment_attr:add')")
    @Log(title = "设备信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CzEquipmentAttr czEquipmentAttr)
    {
        return toAjax(czEquipmentAttrService.insertCzEquipmentAttr(czEquipmentAttr));
    }

    /**
     * 修改设备信息
     */
    @ApiOperation(value = "修改设备信息")
    @PreAuthorize("@ss.hasPermi('business:equipment_attr:edit')")
    @Log(title = "设备信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CzEquipmentAttr czEquipmentAttr)
    {
        return toAjax(czEquipmentAttrService.updateCzEquipmentAttr(czEquipmentAttr));
    }

    /**
     * 删除设备信息
     */
    @ApiOperation(value = "删除设备信息")
    @PreAuthorize("@ss.hasPermi('business:equipment_attr:remove')")
    @Log(title = "设备信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(czEquipmentAttrService.deleteCzEquipmentAttrByIds(ids));
    }
}
